package com.ruoyi.project.zxmes.dv.domain;

import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.Data;

import java.io.Serializable;
import java.util.List;
import java.util.stream.Collectors;


/**
 * Treeselect树结构实体类
 *
 * @author mn
 */
@Data
public class TreeSelectMes implements Serializable {
    private static final long serialVersionUID = 1L;

    /**
     * 节点ID
     */
    private Long id;

    /**
     * 节点名称
     */
    private String label;

    /**
     * 子节点
     */
    @JsonInclude(JsonInclude.Include.NON_EMPTY)
    private List<TreeSelectMes> children;

    public TreeSelectMes() {
    }

    public TreeSelectMes(DvMachineryType dvMachineryType) {
        this.id = dvMachineryType.getMachineryTypeId();
        this.label = dvMachineryType.getMachineryTypeName();
        this.children = dvMachineryType.getChildren().stream().map(TreeSelectMes::new).collect(Collectors.toList());
    }

}
